/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */
package com.iecg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.iecg.api.entity.IecgUser;
import com.iecg.mapper.IecgUserMapper;
import com.iecg.service.IecgUserService;
import com.pig4cloud.pigx.common.security.service.PigxUser;
import com.pig4cloud.pigx.common.security.util.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * 用户基本信息
 *
 * @author pigx code generator
 * @date 2019-08-21 10:03:00
 */
@Service
@Slf4j
public class IecgUserServiceImpl extends ServiceImpl<IecgUserMapper, IecgUser> implements IecgUserService {


	@Override
	public IecgUser loadIecgUserByName(String username) {
		return getOne(new QueryWrapper<IecgUser>() {
			@Override
			public IecgUser getEntity() {
				IecgUser iecgUser = new IecgUser();
				iecgUser.setName(username);
				return iecgUser;
			}
		});
	}

	@Override
	public IecgUser getSecurityUser() {
		PigxUser pigxUser = SecurityUtils.getUser();
		String username = pigxUser.getUsername();
		IecgUser iecgUser = loadIecgUserByName(username);
		return iecgUser;
	}


}
